/* linkit.js
 * By François Leporcq
 * MIT Licensed.
 */
var Linker = $Class.extend({
    _className: "Linker",
    init: function(){
    },
    linkit: function(fromShape, toShape, link){
        if(link == null){
            var link = new Link();
        }
        if(!(link instanceof AbstractLink)){
            throw new Error("Linker.linkit() link param is not an instance of AbstractLink");
        }
        if(!fromShape.implementationOf(Linkable)){
            throw new Error("Linker.linkit() fromShape param does not implement Linkable");
        }
        if(!toShape.implementationOf(Linkable)){
            throw new Error("Linker.linkit() toShape param does not implement Linkable");
        }
        link.setFromShape(fromShape);
        link.setToShape(toShape);
        fromShape.addLink(link);
        toShape.addLink(link);
        link.computeStartEnd();
        return link;
    }
});
